home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Headers / misckit / Miscdaemon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-16  |  1.4 KB  |  53 lines

  1. /*  Functions to turn a program into a daemon, handle signals, manage
  2.  *  a log file facility, and do memory allocation checking.
  3.  *
  4.  *  Copyright (c) 1994 Christopher J. Kane.
  5.  *
  6.  *  This software is subject to the terms of the MiscKit license
  7.  *  agreement. Refer to the license document included with the
  8.  *  MiscKit distribution for these terms.
  9.  *
  10.  *  Version 1.0 (24 March 1994)
  11.  */
  12.  
  13. #if !defined(_DAEMON_H)
  14. #define _DAEMON_H 1
  15. #include <sys/types.h>
  16. #include <sys/syslog.h>
  17.  
  18. #if defined(_AIX)
  19.     #include <sys/select.h>
  20. #endif
  21.  
  22. /* Imported variables (must be exported from elsewhere in a program) */
  23.  
  24. /* now declared statically inside Miscdaemon.c:
  25.     extern int debug;
  26.     Use the accessor functions below: */
  27.     
  28. int Misc_daemon_debug();
  29. void Misc_daemon_set_debug(int flag);
  30.  
  31. /* Exported variables */
  32.  
  33. extern int daemon_pid;
  34. extern char *daemon_name;
  35. extern char *daemon_host;
  36.  
  37. /* Exported functions */
  38.  
  39. void daemonize(char *prog_name, char *log_fn, int log_facility, char *safe_dir,
  40.         char *lockf_dir, fd_set *ignfds, int loghup_sig, int *ignsigs);
  41. #define daemon_alloc(SIZE) _daemon_alloc(SIZE, __FILE__, __LINE__)
  42. #define daemon_free(BLOCK) _daemon_free(BLOCK, __FILE__, __LINE__)
  43. void daemon_log(int prio, ...);
  44. void daemon_exit(int exit_val);
  45.  
  46. /* Exported macros */
  47.  
  48. #define daemon_assert(E) ((!debug || (E)) ? (void)0 : \
  49.     daemon_log(LOG_DEBUG, "%s:%d: assertion \"" #E "\" failed", \
  50.     __FILE__, __LINE__), daemon_exit(2))
  51.  
  52. #endif /* _DAEMON_H */
  53.